package com.liu.cloud.factory;

import com.liu.cloud.fiegn.RemoteStockFeignService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 *
 * 库存服务降级处理，降级需要手动启动
 *   hystrix:
 *     enabled: true
 *
 * @author LIU
 * @version 1.0
 * @description: TODO
 * @date 2023/7/29 11:04
 */
@Component
@Slf4j
public class RemoteStockFeignFallbackFactory implements FallbackFactory<RemoteStockFeignService> {

    @Override
    public RemoteStockFeignService create(Throwable throwable) {
        log.error("库存服务调用失败了",throwable);
        return new RemoteStockFeignService() {
            @Override
            public String reduce2() {
                return "服务调用失败，降级了";
            }
        };
    }
}
